import sympy


def sympy_derivative():
    x = sympy.sympify('x')
    y = x ** 3 + x
    return sympy.diff(y, x)


if __name__ == '__main__':
    func = sympy_derivative()
    print(func)
    # 将x等于6代入计算，结果为109
    print(func.evalf(subs={'x': 6}))
